<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //10、将数组[1,2,7,4,9,6,8,3,10,5]进行排序，
    //升序结果为：[1,2,3,4,5,6,7,8,9,10]，
    //倒序结果：[10,9,8,7,6,5,4,3,2,1]
    let num = [1, 2, 7, 4, 9, 6, 8, 3, 10, 5];

    //升序
    num.sort(function (a, b) {
        return a - b;
    });
    console.log(num);


    //倒序
    num.sort(function (a, b) {
        return b - a;
    });
    console.log(num);
</script>

</html>